﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace MedievalGameProject
{
    public class Bow : Weapon
    {
        public Bow(Game1 game, Character owner) : base(game, owner)
        {
            model = new BasicModel(game, game.Content.Load<Model>(@"Models\bow"), 0.15f);
            modelOffsetVec3 = new Vector3(0, 1.8f, -2.5f);
            modelOffset = Matrix.CreateTranslation(modelOffsetVec3.X, modelOffsetVec3.Y, modelOffsetVec3.Z);

            wa.damage = 1;
            wa.shotSpeed = 3;
        }

        public override void BeginFire()
        {
            BasicModel arrowModel = new BasicModel(Game1.instance, Game1.instance.Content.Load<Model>(@"Models\arrow"));
            arrowModel.worldRotation *= Matrix.CreateRotationY((float) Math.PI);

            Vector3 scale, location;
            Quaternion rot;
            world.Decompose(out scale, out rot, out location);

            Projectile arrow = new Projectile(Game1.instance, arrowModel, location,
                Game1.camera.cameraDirection, wa.shotSpeed, wa.damage, 0, owner);

            Game1.SendShootArrowMessage(location, Game1.camera.cameraDirection, wa.shotSpeed);

            Game1.actorManager.ScheduleAddActor(arrow);
        }

        public override void BeginFire(Vector3 location, Vector3 direction, float speed)
        {
            BasicModel arrowModel = new BasicModel(Game1.instance, Game1.instance.Content.Load<Model>(@"Models\arrow"));
            arrowModel.worldRotation *= Matrix.CreateRotationY((float)Math.PI);

            Vector3 scale, loc;
            Quaternion rot;
            world.Decompose(out scale, out rot, out loc);

            Projectile arrow = new Projectile(Game1.instance, arrowModel, location,
                direction, speed, wa.damage, 0, owner);

            Game1.actorManager.ScheduleAddActor(arrow);
        }
    }
}
